﻿#nullable disable
using Android.Hardware.Camera2;

namespace Camera2Demo
{
    internal class CameraCaptureSessionStateCallback : CameraCaptureSession.
        StateCallback
    {
        private readonly Awaiter _awaiter = new Awaiter();
        public bool IsOk { get; set; }
        public CameraCaptureSession? Session { get; set; }

        public Awaiter GetAwaiter()
        {
            return _awaiter;
        }
        public override void OnConfigured(CameraCaptureSession? session)
        {
            Session = session;
            IsOk = true;
            _awaiter.Completed();
        }
        public override void OnConfigureFailed(CameraCaptureSession? session)
        {
            Session = session;
            IsOk = false;
            _awaiter.Completed();
        }
    }
}